Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

686
Visualizações
How to pass variable to "data-target=" angular 2

I'm working with angular 2 typescript and i want to create a toggle collapse list. This is simple with single id and data-target but i loop throught a list so i have dynamic id names. I want to pass a variable in my data-target so i can reach the dynamic names of the id's. something like this:

<a data-toggle="collapse" data-target="#{{theme.themeId}}>collapseHere </a> but this gives me a syntax error.

Is it possibly to pass variables with a data-target?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You could used attribute binding. Something like that:

[attr.data-target]="'#' + theme.themeId"
over 4 years ago · Santiago Trujillo Relatório

0

Yes exactly you can use

*ngFor="a of Array; index as i;"

and

[attr.data-target]="'#test' + i"

and

name="test{{i}}
over 4 years ago · Santiago Trujillo Relatório

0

To pass a variable in Angular 7 you can use it just like:

[attr.data-target] = "theme.themeId"
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda